﻿<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>主页</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/themes/IconExtension.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/china.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/echarts.js"></script>
<script type="text/javascript">
	<!--菜单处理-->
    /*jquery代码*/
   $(function(){

       //修改密码对话会话框
       $("#updateDiv1").dialog({
           width:300,
           title:"修改密码对话框",
           height:200,
           closed:true,
           buttons:"#updateDialogBtn1"
       });
       // 1.获取数据库菜单数据 ajax
       $.ajax({
           url:"${pageContext.request.contextPath}/getMenu",
           type:"get",
           dataType:"JSON",
           success:function (data) {
               console.info(data);
               // 2.对数据做展示 循环
               // 循环参数详细 被循环数据（集合数据） 函数 函数参数 1.下标 2.被遍历到的数据
               $.each(data,function(index,first){
                   // 3.取出一级菜单中的二级菜单数据  再child属性中
                   var c = "";
                   $.each(first.list,function (index1,second) {
                       c += "<div style='text-align: center'><a href='#' class='easyui-linkbutton' data-options=\"iconCls:'icon-search',plain:true\" onclick=\"addTabs('" + second.menuName + "','" + second.menuUrl + "')\">" + second.menuName + "</a></div>";
                   });

                   $('#aa').accordion('add', {
                       title: first.menuName,
                       content: c,
                       selected: false
                   });
               })
           }
       });
   })
    /*js代码*/
    function openUpdatePasswordDialog(){
        $("#updateDiv1").dialog("open")
    }
    function doUpdate(){
        //执行修改操作
        //通过form控件的submit方法提交表单
        $("#updateForm1").form("submit",{
            url:"updatePassword",
            success:function(data){
                //alert(data);
                //data就是一个json串
                var jsObj = JSON.parse(data);
                if(jsObj.isUpdate){
                    //把修改对话框关闭掉
                    alert("修改成功");
                    $("#updateDiv1").dialog("close");
                    window.location="../login.jsp"
                }else{
                    alert("修改失败，请确认");
                }
            }
        });
    }
    function doLoginOut(){
        //执行注销操作
       window.location="${pageContext.request.contextPath}/admin/loginOut"
    }
    function addTabs(menuName,menuUrl) {
        var flag = $("#tt").tabs("exists", menuName);
        if(flag){
            $("#tt").tabs("select", menuName);
        }else {
            $('#tt').tabs('add',{
                title:menuName,
                href:"${pageContext.request.contextPath}"+menuUrl,
                closable:true,
                tools:[{
                    iconCls:'icon-mini-refresh',
                    handler:function(){
                        alert('refresh');
                    }
                }]
            });
        }

    }
</script>

</head>
<body class="easyui-layout">   
    <div data-options="region:'north',split:true" style="height:60px;background-color:  #5C160C">
    	<div style="font-size: 24px;color: #FAF7F7;font-family: 楷体;font-weight: 900;width: 500px;float:left;padding-left: 20px;padding-top: 10px" >后台管理系统</div>
    	<div style="font-size: 16px;color: #FAF7F7;font-family: 楷体;width: 300px;float:right;padding-top:15px">欢迎您:${sessionScope.login.userName} &nbsp;
            <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick="openUpdatePasswordDialog()">修改密码</a>&nbsp;
            &nbsp<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-01'" onclick="doLoginOut()">退出系统</a></div>
    </div>
    <div data-options="region:'south',split:true" style="height: 40px;background: #5C160C">
    	<div style="text-align: center;font-size:15px; color: #FAF7F7;font-family: 楷体" > </div>
    </div>
    <div data-options="region:'west',title:'导航菜单',split:true" style="width:220px;">
        <%--accordion--%>
    	<div id="aa" class="easyui-accordion" data-options="fit:true">
        </div>
    </div>
    <div data-options="region:'center'">
        <%--tabs--%>
    	<div id="tt" class="easyui-tabs" data-options="fit:true,narrow:true,pill:true">
		    <div title="主页" data-options="iconCls:'icon-neighbourhood',"  style="background-image:url(${pageContext.request.contextPath}/main/image/shouye.jpg);background-repeat: no-repeat;background-size:100% 100%;"></div>
		</div>
    </div>

    <div id="updateDiv1">
        <form id="updateForm1" method="post">
            <input type="hidden" name="id" id="id" value="${sessionScope.login.id}"/></br>
            用户名：<input id="userName" type="text" readonly="readonly" name="userName" value="${sessionScope.login.userName}"/><br/>
            密码:<input id="password" type="text" name="password" value="">
            <!-- <input type="button" value="修改" onclick="doUpdate()"/> -->
        </form>
    </div>

    <div id="updateDialogBtn1">
        <a href="javascript:void(0)" onclick="doUpdate()" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改</a>
    </div>
</body> 
</html>